{
 "cells": [
  {
   "cell_type": "markdown",
   "id": "e6a31fa4",
   "metadata": {},
   "source": "# L2正则化使用torch框架的简洁实现"
  },
  {
   "cell_type": "code",
   "id": "30fc7fcf",
   "metadata": {
    "ExecuteTime": {
     "end_time": "2025-08-12T13:39:29.913502Z",
     "start_time": "2025-08-12T13:39:26.396083Z"
    }
   },
   "source": [
    "import torch\n",
    "from torch.utils import data\n",
    "from d2l import torch as d2l\n",
    "import numpy as np"
   ],
   "outputs": [],
   "execution_count": 1
  },
  {
   "cell_type": "code",
   "id": "dc890b93",
   "metadata": {
    "ExecuteTime": {
     "end_time": "2025-08-12T13:39:30.197651Z",
     "start_time": "2025-08-12T13:39:30.194140Z"
    }
   },
   "source": [
    "true_weight = torch.tensor([2,11.5,-10,7,18.1,3,2,11,7,8])\n",
    "true_bias = 4.2"
   ],
   "outputs": [],
   "execution_count": 2
  },
  {
   "cell_type": "code",
   "id": "b2d4826d",
   "metadata": {
    "ExecuteTime": {
     "end_time": "2025-08-12T13:39:30.220698Z",
     "start_time": "2025-08-12T13:39:30.216469Z"
    }
   },
   "source": [
    "features,labels = d2l.synthetic_data(true_weight,true_bias,10000) ## 生成数据"
   ],
   "outputs": [],
   "execution_count": 3
  },
  {
   "cell_type": "code",
   "id": "fea46f95",
   "metadata": {
    "ExecuteTime": {
     "end_time": "2025-08-12T13:39:30.246797Z",
     "start_time": "2025-08-12T13:39:30.243303Z"
    }
   },
   "source": [
    "def load_array(data_arrays: tuple, batch_size: int, is_train=True) -> data.DataLoader:\n",
    "    \"\"\"\n",
    "    使用框架构建批次数据集\n",
    "    :param data_arrays 元组格式，应传入一个由feature和label构成的配对元组\n",
    "    :param batch_size int，定义批次大小\n",
    "    \"\"\"\n",
    "    dataset = data.TensorDataset(*data_arrays)\n",
    "    return data.DataLoader(dataset, batch_size, shuffle=is_train)\n"
   ],
   "outputs": [],
   "execution_count": 4
  },
  {
   "cell_type": "code",
   "id": "cb8a3845",
   "metadata": {
    "ExecuteTime": {
     "end_time": "2025-08-12T13:39:30.270276Z",
     "start_time": "2025-08-12T13:39:30.261936Z"
    }
   },
   "source": [
    "batch_size = 40\n",
    "data_iter = load_array((features,labels),batch_size)\n",
    "## DataLoader为迭代器对象，每次仅迭代一个batch\n",
    "print(iter(data_iter))\n",
    "print('x\\n',next(iter(data_iter))[0],'\\n','y\\n',next(iter(data_iter))[1])"
   ],
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "<torch.utils.data.dataloader._SingleProcessDataLoaderIter object at 0x000001D2899FD460>\n",
      "x\n",
      " tensor([[ 3.2735e-01, -6.9993e-01,  1.0158e+00,  1.7680e+00, -4.7352e-01,\n",
      "         -2.6614e-01, -2.5964e-01, -8.0086e-01,  1.0435e+00,  1.3662e-01],\n",
      "        [ 4.3923e-01, -1.2667e+00, -9.1228e-01, -5.0026e-01,  1.1686e+00,\n",
      "         -5.5056e-01,  2.7450e-01,  3.5519e-01,  1.2487e+00,  5.8223e-01],\n",
      "        [ 2.9365e-01, -1.7475e-01, -2.3945e-01, -3.0974e-02, -6.5622e-01,\n",
      "          5.7023e-01, -5.3374e-01,  1.3411e+00,  2.9411e-01,  6.6707e-01],\n",
      "        [ 1.1649e+00, -7.6445e-01,  1.2471e-01,  5.7533e-01, -3.2625e-01,\n",
      "          4.6592e-01,  1.4593e+00,  5.4119e-01,  1.7441e+00, -2.0656e+00],\n",
      "        [-1.4295e+00,  7.9558e-01, -1.1898e+00, -1.3676e+00, -6.6543e-01,\n",
      "         -6.6882e-01,  2.5841e-01,  1.5637e+00, -7.3162e-01,  8.7396e-01],\n",
      "        [-5.0168e-01,  1.2496e+00,  6.7240e-01,  5.4781e-01,  5.8784e-01,\n",
      "          2.5364e-03, -1.1746e+00,  2.2163e+00,  2.5051e-01,  9.0481e-01],\n",
      "        [-9.9455e-01,  8.5466e-01,  1.1569e-01,  6.8743e-01,  1.1494e-01,\n",
      "         -1.3717e+00,  1.3251e+00,  1.3252e+00, -8.1733e-01,  1.0431e+00],\n",
      "        [-2.3566e-01, -6.9768e-01, -1.4556e+00,  3.6813e-01,  9.7157e-01,\n",
      "          1.3967e+00, -1.2628e+00, -4.9172e-02,  6.2161e-01, -5.9001e-01],\n",
      "        [ 5.9608e-01,  1.0574e-01,  3.2233e-02, -1.4598e+00,  2.0220e+00,\n",
      "         -3.2077e-01, -2.9939e+00,  1.5605e-01,  1.1170e+00,  5.2945e-01],\n",
      "        [-2.0335e+00,  4.2858e-01,  6.6235e-01, -5.0761e-01, -4.4224e-01,\n",
      "         -1.5521e+00,  8.4358e-01,  1.6486e+00, -1.5322e+00, -1.7695e-02],\n",
      "        [ 6.5309e-01, -7.7413e-01,  4.6435e-01,  1.2890e+00, -2.4724e-01,\n",
      "          7.3630e-01, -1.0708e+00, -1.2716e-01,  3.4341e-01, -2.9944e-01],\n",
      "        [ 8.3402e-01, -1.5569e+00, -6.3930e-01, -1.3443e+00, -7.9019e-01,\n",
      "         -1.7810e+00, -1.3269e+00, -4.3721e-01,  6.4259e-01,  8.3769e-01],\n",
      "        [-6.0553e-01,  3.0862e-01,  4.6536e-01,  8.4263e-03, -9.5774e-01,\n",
      "          5.9153e-01,  1.2286e+00,  1.3756e+00, -3.0929e-01,  7.5131e-02],\n",
      "        [-1.0778e+00, -5.4473e-01,  2.1300e+00,  4.6816e-01,  1.7952e+00,\n",
      "          5.6168e-01, -2.0666e+00, -5.7290e-01,  1.1233e+00,  9.3045e-01],\n",
      "        [-5.6489e-01, -4.9765e-01, -9.8127e-01, -3.2509e-02,  6.4531e-01,\n",
      "         -3.6747e-01, -7.5516e-01,  2.4635e+00, -1.3919e-01, -3.2001e-01],\n",
      "        [-1.3184e-01, -1.5073e+00,  1.2837e+00, -3.5024e-01,  7.7022e-01,\n",
      "         -4.6560e-01,  6.2739e-01,  6.4248e-01, -2.0061e+00, -6.1329e-01],\n",
      "        [-3.8653e-01, -4.8270e-01, -3.1200e+00,  9.5700e-01,  1.1912e+00,\n",
      "          8.7484e-01, -2.0771e-01, -9.8897e-01,  8.4895e-01,  1.8363e-02],\n",
      "        [-1.1781e+00,  9.8005e-01, -2.1690e+00,  8.0445e-01, -9.8684e-01,\n",
      "          6.8727e-01, -4.5431e-01,  2.2186e+00,  1.9132e+00, -4.0480e-01],\n",
      "        [-1.2818e-01,  3.7254e-01,  4.8550e-01,  3.1160e-01,  2.5501e-01,\n",
      "         -6.2461e-01,  1.0780e+00,  8.5833e-01,  6.5915e-01, -9.3926e-01],\n",
      "        [ 1.0736e+00, -5.7695e-01, -1.2405e+00,  1.3435e+00, -7.9089e-01,\n",
      "          3.8814e-01, -2.3144e-01,  8.2570e-01, -7.7161e-01,  1.4542e+00],\n",
      "        [-7.5167e-01, -5.6505e-01, -9.9779e-01, -7.0578e-01, -7.9075e-02,\n",
      "          7.8615e-01,  7.2278e-01,  1.5946e+00, -1.4770e+00, -2.9239e-01],\n",
      "        [ 1.0741e+00, -5.5105e-01,  1.6520e+00,  3.7860e-01, -9.5053e-01,\n",
      "         -1.4477e+00, -1.7780e-01, -1.0625e+00, -3.7070e-01,  7.7310e-01],\n",
      "        [-1.5639e-01,  1.7363e+00, -2.6549e-01,  2.1801e+00, -4.3841e-01,\n",
      "         -5.1256e-01, -1.2743e-01, -8.0129e-01, -9.5986e-02,  5.1516e-01],\n",
      "        [ 4.9097e-01, -8.0165e-01, -4.2489e-01,  1.6451e+00, -1.3156e+00,\n",
      "         -6.8627e-01, -7.4909e-01,  4.4867e-01, -1.1642e+00,  1.9559e-01],\n",
      "        [-7.0097e-01, -6.0846e-01,  3.5828e-01, -6.2860e-01,  1.3220e+00,\n",
      "          1.3042e+00,  2.3538e-01, -8.0014e-01, -8.6770e-01, -1.3001e-01],\n",
      "        [ 1.9333e+00, -2.3660e-01, -8.8987e-01, -8.5844e-01, -2.2372e+00,\n",
      "          3.9067e-01,  1.0474e+00,  1.5151e+00, -6.2080e-01,  2.2617e+00],\n",
      "        [ 1.4655e-01,  3.8505e-01,  4.0431e-01,  5.0561e-01, -8.4140e-02,\n",
      "          1.2024e-01, -2.3370e-01, -8.3890e-01, -5.2485e-02, -6.3287e-01],\n",
      "        [ 1.6348e+00, -3.6395e+00, -1.6641e+00, -4.6471e-01,  5.1297e-01,\n",
      "         -4.8661e-01,  1.2972e-01, -2.0954e+00,  2.7345e-02,  4.6255e-01],\n",
      "        [ 4.3218e-01, -1.1442e-01,  1.6263e-01, -5.9336e-01, -1.5393e-01,\n",
      "         -1.5549e+00, -4.6822e-01, -9.6879e-01,  1.5141e+00, -8.7016e-01],\n",
      "        [-1.2388e+00,  1.3765e-01,  5.1944e-01,  9.0243e-01,  5.2099e-01,\n",
      "         -9.7186e-01,  1.2815e+00, -7.9495e-01, -8.2909e-01, -4.7449e-01],\n",
      "        [ 3.2822e-02,  9.0886e-01, -2.4951e+00,  2.1507e-01,  7.7364e-01,\n",
      "          3.1778e+00,  8.8498e-01,  9.5514e-01, -7.8859e-01,  1.4781e+00],\n",
      "        [-1.6076e+00, -1.4162e+00, -6.5085e-01,  5.7634e-01, -3.1788e-01,\n",
      "          6.6711e-01,  2.8292e-01,  8.7363e-01, -1.0090e+00, -2.5371e-01],\n",
      "        [ 2.6248e-01,  1.0471e+00,  1.0747e+00, -1.1382e-01, -1.3427e+00,\n",
      "         -1.8674e+00, -4.1931e-01, -8.0561e-01,  6.5286e-01, -1.2933e+00],\n",
      "        [ 8.3358e-01,  2.6445e-01,  2.3623e-01,  1.0340e+00, -6.9424e-01,\n",
      "          1.8604e+00,  1.1334e+00,  1.5133e-01, -2.0963e+00, -1.7347e+00],\n",
      "        [-7.6059e-01,  1.7168e+00, -3.5112e-01,  8.2160e-02,  4.6724e-01,\n",
      "          8.6088e-01,  1.9520e+00, -1.7534e+00, -1.8824e+00, -1.9962e+00],\n",
      "        [ 9.8378e-01,  7.6842e-02, -7.8080e-02, -1.5294e-01, -1.3458e+00,\n",
      "         -3.1664e-01, -8.2118e-01, -3.6603e-01, -2.1251e+00,  5.4695e-02],\n",
      "        [-2.5438e-02, -2.1264e-01,  4.0826e-01,  5.4233e-01, -1.0727e+00,\n",
      "         -5.3300e-01,  2.1805e+00, -5.1235e-01, -9.8368e-01,  3.3403e-01],\n",
      "        [ 6.8320e-01, -5.2551e-01, -1.0152e+00,  1.7426e-01,  1.0110e+00,\n",
      "         -1.7735e+00,  4.3201e-01, -2.5222e+00,  6.3144e-01, -7.6561e-01],\n",
      "        [ 5.1654e-01, -3.9024e-01,  1.0775e+00, -1.2577e+00,  1.4602e+00,\n",
      "          2.6591e-01,  1.9408e-01,  4.9102e-01,  1.7906e+00,  3.8068e-01],\n",
      "        [-7.1913e-01, -1.9732e+00, -1.6322e-01,  1.2954e-01, -2.2645e-01,\n",
      "         -2.2659e+00, -4.5826e-01, -3.3686e-01, -2.4869e-01, -1.3197e-02]]) \n",
      " y\n",
      " tensor([[-25.6681],\n",
      "        [ 21.0923],\n",
      "        [  4.8648],\n",
      "        [ 60.0178],\n",
      "        [ 21.9043],\n",
      "        [-13.9971],\n",
      "        [ 35.7945],\n",
      "        [ 42.4894],\n",
      "        [ 16.9700],\n",
      "        [ 40.3747],\n",
      "        [-20.1854],\n",
      "        [  5.3055],\n",
      "        [  7.2149],\n",
      "        [ 21.7940],\n",
      "        [  3.8184],\n",
      "        [-16.9324],\n",
      "        [-20.6934],\n",
      "        [-14.0615],\n",
      "        [  4.5817],\n",
      "        [  2.0572],\n",
      "        [  3.4089],\n",
      "        [ 37.0214],\n",
      "        [-22.9715],\n",
      "        [ 49.4267],\n",
      "        [ 36.2816],\n",
      "        [ -0.6883],\n",
      "        [  5.4084],\n",
      "        [ -6.6398],\n",
      "        [ -8.3455],\n",
      "        [  3.2456],\n",
      "        [ 14.8094],\n",
      "        [ 14.2242],\n",
      "        [-59.7553],\n",
      "        [-54.6458],\n",
      "        [-25.0231],\n",
      "        [  3.3910],\n",
      "        [ 67.8242],\n",
      "        [-22.1503],\n",
      "        [-30.2600],\n",
      "        [-20.8568]])\n"
     ]
    }
   ],
   "execution_count": 5
  },
  {
   "cell_type": "code",
   "id": "121457bb",
   "metadata": {
    "ExecuteTime": {
     "end_time": "2025-08-12T13:39:30.292918Z",
     "start_time": "2025-08-12T13:39:30.288880Z"
    }
   },
   "source": [
    "from torch import nn ## 导入神经网络层库\n",
    "net = nn.Sequential(\n",
    "    nn.Linear(in_features = len(features[0]),out_features = 1)\n",
    ") ## nn.Sequential用于多神经网络层组合的流水线，这里仅包含nn.Linear线性层"
   ],
   "outputs": [],
   "execution_count": 6
  },
  {
   "cell_type": "code",
   "id": "92524088",
   "metadata": {
    "ExecuteTime": {
     "end_time": "2025-08-12T13:39:30.307741Z",
     "start_time": "2025-08-12T13:39:30.303721Z"
    }
   },
   "source": [
    "print(net[0].weight.data)\n",
    "print(net[0].bias.data)"
   ],
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "tensor([[-0.0620, -0.2187,  0.0431,  0.2184, -0.0866,  0.2722,  0.0345,  0.0032,\n",
      "         -0.1375,  0.0141]])\n",
      "tensor([-0.1005])\n"
     ]
    }
   ],
   "execution_count": 7
  },
  {
   "cell_type": "code",
   "id": "f22fc67d",
   "metadata": {
    "ExecuteTime": {
     "end_time": "2025-08-12T13:39:30.335745Z",
     "start_time": "2025-08-12T13:39:30.330748Z"
    }
   },
   "source": [
    "net[0].weight.data.normal_(0,0.01) ## 将权重标准化\n",
    "net[0].bias.data.fill_(0) ## 设置bias为0"
   ],
   "outputs": [
    {
     "data": {
      "text/plain": [
       "tensor([0.])"
      ]
     },
     "execution_count": 8,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "execution_count": 8
  },
  {
   "cell_type": "code",
   "id": "0a8f5626",
   "metadata": {
    "ExecuteTime": {
     "end_time": "2025-08-12T13:39:30.364160Z",
     "start_time": "2025-08-12T13:39:30.361305Z"
    }
   },
   "source": [
    "loss = nn.MSELoss() ## 定义损失函数为均方误差"
   ],
   "outputs": [],
   "execution_count": 9
  },
  {
   "cell_type": "code",
   "id": "0815a6c9",
   "metadata": {
    "ExecuteTime": {
     "end_time": "2025-08-12T13:39:30.385144Z",
     "start_time": "2025-08-12T13:39:30.382144Z"
    }
   },
   "source": [
    "'''\n",
    "定义参数调优器为SGD梯度下降法，net.parameters()为神经网络层组合参数\n",
    "要求SGD对神经网络层组合参数进行调优\n",
    "'''\n",
    "trainer = torch.optim.SGD(\n",
    "    [\n",
    "        {'params': net[0].weight, 'weight_decay': 0.5}, ## 由于对bias进行正则对模型泛化能力改变影响较弱，仅指定权重进行正则化处理，optim类可接受字典列表以指定优化范围和策略，全局参数需要移出字典列表\n",
    "        {'params': net[0].bias}\n",
    "    ],\n",
    "    lr = 0.1\n",
    ")\n"
   ],
   "outputs": [],
   "execution_count": 10
  },
  {
   "cell_type": "code",
   "id": "2f483838",
   "metadata": {
    "ExecuteTime": {
     "end_time": "2025-08-12T13:40:58.600761Z",
     "start_time": "2025-08-12T13:39:30.414110Z"
    }
   },
   "source": [
    "num_epochs = 1000\n",
    "for epoch in range(num_epochs):\n",
    "    for X,y in data_iter:\n",
    "        l = loss(net(X),y) ## 计算均方误差 net(x)用于计算特征输入对应的y值\n",
    "        trainer.zero_grad() ## 清空梯度\n",
    "        l.backward() ## 计算梯度\n",
    "        trainer.step() ## 更新模型参数\n",
    "    L = loss(net(features),labels)\n",
    "    print(f'epoch {epoch}, loss {L}')"
   ],
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "epoch 0, loss 32.200355529785156\n",
      "epoch 1, loss 31.43218421936035\n",
      "epoch 2, loss 36.0433235168457\n",
      "epoch 3, loss 41.388980865478516\n",
      "epoch 4, loss 41.73806381225586\n",
      "epoch 5, loss 35.14723205566406\n",
      "epoch 6, loss 32.18455123901367\n",
      "epoch 7, loss 31.728137969970703\n",
      "epoch 8, loss 33.61810302734375\n",
      "epoch 9, loss 33.260581970214844\n",
      "epoch 10, loss 43.28236389160156\n",
      "epoch 11, loss 40.33305358886719\n",
      "epoch 12, loss 35.18672180175781\n",
      "epoch 13, loss 33.10607147216797\n",
      "epoch 14, loss 39.776756286621094\n",
      "epoch 15, loss 31.098621368408203\n",
      "epoch 16, loss 32.48887252807617\n",
      "epoch 17, loss 40.84889602661133\n",
      "epoch 18, loss 40.297157287597656\n",
      "epoch 19, loss 33.775535583496094\n",
      "epoch 20, loss 38.764007568359375\n",
      "epoch 21, loss 33.716651916503906\n",
      "epoch 22, loss 44.83149719238281\n",
      "epoch 23, loss 30.65410041809082\n",
      "epoch 24, loss 27.58440589904785\n",
      "epoch 25, loss 31.903362274169922\n",
      "epoch 26, loss 36.13337326049805\n",
      "epoch 27, loss 35.23405456542969\n",
      "epoch 28, loss 43.313385009765625\n",
      "epoch 29, loss 41.858421325683594\n",
      "epoch 30, loss 34.506439208984375\n",
      "epoch 31, loss 28.952930450439453\n",
      "epoch 32, loss 31.928268432617188\n",
      "epoch 33, loss 29.44700050354004\n",
      "epoch 34, loss 29.356412887573242\n",
      "epoch 35, loss 39.27927780151367\n",
      "epoch 36, loss 45.99769973754883\n",
      "epoch 37, loss 39.04997634887695\n",
      "epoch 38, loss 33.43846130371094\n",
      "epoch 39, loss 32.75400924682617\n",
      "epoch 40, loss 27.85566520690918\n",
      "epoch 41, loss 30.833881378173828\n",
      "epoch 42, loss 37.69525146484375\n",
      "epoch 43, loss 36.37433624267578\n",
      "epoch 44, loss 38.976993560791016\n",
      "epoch 45, loss 36.702510833740234\n",
      "epoch 46, loss 39.828182220458984\n",
      "epoch 47, loss 37.598655700683594\n",
      "epoch 48, loss 41.94632339477539\n",
      "epoch 49, loss 35.56815719604492\n",
      "epoch 50, loss 29.708505630493164\n",
      "epoch 51, loss 27.92624282836914\n",
      "epoch 52, loss 27.490962982177734\n",
      "epoch 53, loss 29.82070541381836\n",
      "epoch 54, loss 39.80867004394531\n",
      "epoch 55, loss 34.774776458740234\n",
      "epoch 56, loss 32.56150436401367\n",
      "epoch 57, loss 39.429664611816406\n",
      "epoch 58, loss 33.71217346191406\n",
      "epoch 59, loss 30.76333999633789\n",
      "epoch 60, loss 41.78984451293945\n",
      "epoch 61, loss 36.39131164550781\n",
      "epoch 62, loss 35.645267486572266\n",
      "epoch 63, loss 42.21360397338867\n",
      "epoch 64, loss 37.287139892578125\n",
      "epoch 65, loss 27.58094024658203\n",
      "epoch 66, loss 33.35105514526367\n",
      "epoch 67, loss 37.568641662597656\n",
      "epoch 68, loss 32.34351348876953\n",
      "epoch 69, loss 41.814937591552734\n",
      "epoch 70, loss 36.15339279174805\n",
      "epoch 71, loss 39.90994644165039\n",
      "epoch 72, loss 42.336143493652344\n",
      "epoch 73, loss 40.66746520996094\n",
      "epoch 74, loss 34.315765380859375\n",
      "epoch 75, loss 28.159046173095703\n",
      "epoch 76, loss 47.307159423828125\n",
      "epoch 77, loss 41.2225341796875\n",
      "epoch 78, loss 35.780704498291016\n",
      "epoch 79, loss 33.919227600097656\n",
      "epoch 80, loss 38.21371078491211\n",
      "epoch 81, loss 36.044334411621094\n",
      "epoch 82, loss 42.25025177001953\n",
      "epoch 83, loss 34.00799560546875\n",
      "epoch 84, loss 37.12222671508789\n",
      "epoch 85, loss 40.32844543457031\n",
      "epoch 86, loss 41.49365234375\n",
      "epoch 87, loss 33.51774597167969\n",
      "epoch 88, loss 39.550167083740234\n",
      "epoch 89, loss 26.2946720123291\n",
      "epoch 90, loss 31.61780548095703\n",
      "epoch 91, loss 37.20255661010742\n",
      "epoch 92, loss 41.77978515625\n",
      "epoch 93, loss 36.798561096191406\n",
      "epoch 94, loss 36.37157440185547\n",
      "epoch 95, loss 39.780738830566406\n",
      "epoch 96, loss 29.76960563659668\n",
      "epoch 97, loss 34.70707321166992\n",
      "epoch 98, loss 31.506813049316406\n",
      "epoch 99, loss 43.59120559692383\n",
      "epoch 100, loss 33.82706832885742\n",
      "epoch 101, loss 41.52933120727539\n",
      "epoch 102, loss 28.356306076049805\n",
      "epoch 103, loss 30.904672622680664\n",
      "epoch 104, loss 26.615190505981445\n",
      "epoch 105, loss 37.44534683227539\n",
      "epoch 106, loss 37.91516876220703\n",
      "epoch 107, loss 33.84661102294922\n",
      "epoch 108, loss 39.08616256713867\n",
      "epoch 109, loss 41.47611999511719\n",
      "epoch 110, loss 39.37754440307617\n",
      "epoch 111, loss 32.181983947753906\n",
      "epoch 112, loss 32.035491943359375\n",
      "epoch 113, loss 40.83395004272461\n",
      "epoch 114, loss 44.42045211791992\n",
      "epoch 115, loss 31.189172744750977\n",
      "epoch 116, loss 39.230369567871094\n",
      "epoch 117, loss 36.98182678222656\n",
      "epoch 118, loss 23.16476058959961\n",
      "epoch 119, loss 27.782209396362305\n",
      "epoch 120, loss 31.626155853271484\n",
      "epoch 121, loss 44.69648742675781\n",
      "epoch 122, loss 35.44253158569336\n",
      "epoch 123, loss 32.290855407714844\n",
      "epoch 124, loss 32.639034271240234\n",
      "epoch 125, loss 31.512006759643555\n",
      "epoch 126, loss 38.049522399902344\n",
      "epoch 127, loss 39.1801872253418\n",
      "epoch 128, loss 37.80254364013672\n",
      "epoch 129, loss 34.32149887084961\n",
      "epoch 130, loss 38.111637115478516\n",
      "epoch 131, loss 37.291343688964844\n",
      "epoch 132, loss 32.228450775146484\n",
      "epoch 133, loss 39.12966537475586\n",
      "epoch 134, loss 33.97142028808594\n",
      "epoch 135, loss 33.9039192199707\n",
      "epoch 136, loss 30.28229331970215\n",
      "epoch 137, loss 35.0584831237793\n",
      "epoch 138, loss 34.66044616699219\n",
      "epoch 139, loss 25.408294677734375\n",
      "epoch 140, loss 41.21656799316406\n",
      "epoch 141, loss 39.09187316894531\n",
      "epoch 142, loss 37.42719650268555\n",
      "epoch 143, loss 29.155359268188477\n",
      "epoch 144, loss 44.759910583496094\n",
      "epoch 145, loss 39.18330764770508\n",
      "epoch 146, loss 35.703651428222656\n",
      "epoch 147, loss 33.561912536621094\n",
      "epoch 148, loss 34.52914810180664\n",
      "epoch 149, loss 33.861366271972656\n",
      "epoch 150, loss 25.266921997070312\n",
      "epoch 151, loss 29.500091552734375\n",
      "epoch 152, loss 28.8300724029541\n",
      "epoch 153, loss 30.581859588623047\n",
      "epoch 154, loss 29.003494262695312\n",
      "epoch 155, loss 40.55009460449219\n",
      "epoch 156, loss 41.34836196899414\n",
      "epoch 157, loss 40.99751281738281\n",
      "epoch 158, loss 37.11082077026367\n",
      "epoch 159, loss 32.579341888427734\n",
      "epoch 160, loss 35.832706451416016\n",
      "epoch 161, loss 36.766273498535156\n",
      "epoch 162, loss 28.000524520874023\n",
      "epoch 163, loss 41.2307243347168\n",
      "epoch 164, loss 38.010555267333984\n",
      "epoch 165, loss 33.80191421508789\n",
      "epoch 166, loss 34.09844207763672\n",
      "epoch 167, loss 33.8344612121582\n",
      "epoch 168, loss 31.337493896484375\n",
      "epoch 169, loss 45.174739837646484\n",
      "epoch 170, loss 38.890098571777344\n",
      "epoch 171, loss 35.51947021484375\n",
      "epoch 172, loss 36.3669319152832\n",
      "epoch 173, loss 43.80873489379883\n",
      "epoch 174, loss 38.85073471069336\n",
      "epoch 175, loss 38.46992111206055\n",
      "epoch 176, loss 44.97673034667969\n",
      "epoch 177, loss 36.164466857910156\n",
      "epoch 178, loss 34.25733184814453\n",
      "epoch 179, loss 28.55495262145996\n",
      "epoch 180, loss 30.49607276916504\n",
      "epoch 181, loss 44.776912689208984\n",
      "epoch 182, loss 33.21824264526367\n",
      "epoch 183, loss 35.17941665649414\n",
      "epoch 184, loss 35.56282043457031\n",
      "epoch 185, loss 32.20306396484375\n",
      "epoch 186, loss 30.473602294921875\n",
      "epoch 187, loss 33.594505310058594\n",
      "epoch 188, loss 33.21104431152344\n",
      "epoch 189, loss 34.39903259277344\n",
      "epoch 190, loss 34.23234558105469\n",
      "epoch 191, loss 33.99932861328125\n",
      "epoch 192, loss 32.2919921875\n",
      "epoch 193, loss 32.563812255859375\n",
      "epoch 194, loss 32.988616943359375\n",
      "epoch 195, loss 35.719913482666016\n",
      "epoch 196, loss 40.508934020996094\n",
      "epoch 197, loss 34.21383285522461\n",
      "epoch 198, loss 34.68191146850586\n",
      "epoch 199, loss 37.759735107421875\n",
      "epoch 200, loss 35.48759460449219\n",
      "epoch 201, loss 37.957183837890625\n",
      "epoch 202, loss 39.749298095703125\n",
      "epoch 203, loss 35.951133728027344\n",
      "epoch 204, loss 35.429691314697266\n",
      "epoch 205, loss 40.23286437988281\n",
      "epoch 206, loss 32.25751876831055\n",
      "epoch 207, loss 31.987287521362305\n",
      "epoch 208, loss 32.963600158691406\n",
      "epoch 209, loss 37.09416198730469\n",
      "epoch 210, loss 45.27853012084961\n",
      "epoch 211, loss 32.73543167114258\n",
      "epoch 212, loss 44.551509857177734\n",
      "epoch 213, loss 33.08102035522461\n",
      "epoch 214, loss 38.24617004394531\n",
      "epoch 215, loss 31.69424057006836\n",
      "epoch 216, loss 40.79588317871094\n",
      "epoch 217, loss 27.30324363708496\n",
      "epoch 218, loss 37.47385787963867\n",
      "epoch 219, loss 32.71539306640625\n",
      "epoch 220, loss 35.83909225463867\n",
      "epoch 221, loss 36.78540802001953\n",
      "epoch 222, loss 38.78193664550781\n",
      "epoch 223, loss 37.38581848144531\n",
      "epoch 224, loss 28.53981590270996\n",
      "epoch 225, loss 29.27292823791504\n",
      "epoch 226, loss 41.556976318359375\n",
      "epoch 227, loss 34.108489990234375\n",
      "epoch 228, loss 27.75981330871582\n",
      "epoch 229, loss 25.31352424621582\n",
      "epoch 230, loss 34.35655212402344\n",
      "epoch 231, loss 36.89037322998047\n",
      "epoch 232, loss 33.77981185913086\n",
      "epoch 233, loss 39.58642578125\n",
      "epoch 234, loss 32.83586883544922\n",
      "epoch 235, loss 39.17726135253906\n",
      "epoch 236, loss 35.839115142822266\n",
      "epoch 237, loss 39.034423828125\n",
      "epoch 238, loss 37.616939544677734\n",
      "epoch 239, loss 26.65802764892578\n",
      "epoch 240, loss 40.76064682006836\n",
      "epoch 241, loss 35.940311431884766\n",
      "epoch 242, loss 39.86897277832031\n",
      "epoch 243, loss 37.3995361328125\n",
      "epoch 244, loss 28.280588150024414\n",
      "epoch 245, loss 38.323917388916016\n",
      "epoch 246, loss 33.28986740112305\n",
      "epoch 247, loss 31.383310317993164\n",
      "epoch 248, loss 35.609317779541016\n",
      "epoch 249, loss 29.075368881225586\n",
      "epoch 250, loss 30.531816482543945\n",
      "epoch 251, loss 36.71269989013672\n",
      "epoch 252, loss 37.8642578125\n",
      "epoch 253, loss 35.508140563964844\n",
      "epoch 254, loss 36.392208099365234\n",
      "epoch 255, loss 36.52323913574219\n",
      "epoch 256, loss 40.793212890625\n",
      "epoch 257, loss 39.856964111328125\n",
      "epoch 258, loss 30.104637145996094\n",
      "epoch 259, loss 39.37105178833008\n",
      "epoch 260, loss 28.221324920654297\n",
      "epoch 261, loss 29.8516788482666\n",
      "epoch 262, loss 45.1260871887207\n",
      "epoch 263, loss 28.704753875732422\n",
      "epoch 264, loss 34.61744689941406\n",
      "epoch 265, loss 32.58595275878906\n",
      "epoch 266, loss 32.35857009887695\n",
      "epoch 267, loss 33.19883346557617\n",
      "epoch 268, loss 46.23227310180664\n",
      "epoch 269, loss 34.822025299072266\n",
      "epoch 270, loss 42.458499908447266\n",
      "epoch 271, loss 29.86599349975586\n",
      "epoch 272, loss 36.208473205566406\n",
      "epoch 273, loss 37.46596145629883\n",
      "epoch 274, loss 35.88505554199219\n",
      "epoch 275, loss 39.3179817199707\n",
      "epoch 276, loss 32.4218864440918\n",
      "epoch 277, loss 37.73027801513672\n",
      "epoch 278, loss 43.21842956542969\n",
      "epoch 279, loss 33.829620361328125\n",
      "epoch 280, loss 34.20406723022461\n",
      "epoch 281, loss 31.79961585998535\n",
      "epoch 282, loss 29.558866500854492\n",
      "epoch 283, loss 33.020511627197266\n",
      "epoch 284, loss 35.91584396362305\n",
      "epoch 285, loss 38.70217514038086\n",
      "epoch 286, loss 32.9649543762207\n",
      "epoch 287, loss 31.511096954345703\n",
      "epoch 288, loss 39.58446502685547\n",
      "epoch 289, loss 41.799861907958984\n",
      "epoch 290, loss 41.22676086425781\n",
      "epoch 291, loss 32.98812484741211\n",
      "epoch 292, loss 32.18109893798828\n",
      "epoch 293, loss 33.632102966308594\n",
      "epoch 294, loss 36.667144775390625\n",
      "epoch 295, loss 31.62215232849121\n",
      "epoch 296, loss 34.881343841552734\n",
      "epoch 297, loss 41.3188591003418\n",
      "epoch 298, loss 36.561073303222656\n",
      "epoch 299, loss 30.26661491394043\n",
      "epoch 300, loss 31.208450317382812\n",
      "epoch 301, loss 35.835960388183594\n",
      "epoch 302, loss 32.02348327636719\n",
      "epoch 303, loss 33.3461799621582\n",
      "epoch 304, loss 32.36296844482422\n",
      "epoch 305, loss 33.92024230957031\n",
      "epoch 306, loss 29.072834014892578\n",
      "epoch 307, loss 37.25786590576172\n",
      "epoch 308, loss 32.30634689331055\n",
      "epoch 309, loss 36.67329788208008\n",
      "epoch 310, loss 32.706844329833984\n",
      "epoch 311, loss 42.707088470458984\n",
      "epoch 312, loss 41.838951110839844\n",
      "epoch 313, loss 32.8042106628418\n",
      "epoch 314, loss 37.23630905151367\n",
      "epoch 315, loss 32.072757720947266\n",
      "epoch 316, loss 36.173004150390625\n",
      "epoch 317, loss 35.772071838378906\n",
      "epoch 318, loss 35.66263198852539\n",
      "epoch 319, loss 38.6258659362793\n",
      "epoch 320, loss 38.54642868041992\n",
      "epoch 321, loss 40.72178268432617\n",
      "epoch 322, loss 34.510398864746094\n",
      "epoch 323, loss 35.592472076416016\n",
      "epoch 324, loss 47.69877624511719\n",
      "epoch 325, loss 36.38039779663086\n",
      "epoch 326, loss 43.277862548828125\n",
      "epoch 327, loss 36.98375701904297\n",
      "epoch 328, loss 42.19366455078125\n",
      "epoch 329, loss 28.59723472595215\n",
      "epoch 330, loss 34.20009994506836\n",
      "epoch 331, loss 34.71068572998047\n",
      "epoch 332, loss 35.20017623901367\n",
      "epoch 333, loss 30.2707462310791\n",
      "epoch 334, loss 36.63338851928711\n",
      "epoch 335, loss 29.67011833190918\n",
      "epoch 336, loss 36.788818359375\n",
      "epoch 337, loss 41.88153076171875\n",
      "epoch 338, loss 44.912471771240234\n",
      "epoch 339, loss 37.97007369995117\n",
      "epoch 340, loss 38.1820182800293\n",
      "epoch 341, loss 40.66189193725586\n",
      "epoch 342, loss 32.76563262939453\n",
      "epoch 343, loss 28.190275192260742\n",
      "epoch 344, loss 33.91748809814453\n",
      "epoch 345, loss 35.940574645996094\n",
      "epoch 346, loss 34.20759582519531\n",
      "epoch 347, loss 34.33187484741211\n",
      "epoch 348, loss 41.06931686401367\n",
      "epoch 349, loss 37.11227035522461\n",
      "epoch 350, loss 38.20501708984375\n",
      "epoch 351, loss 37.41584396362305\n",
      "epoch 352, loss 39.08020782470703\n",
      "epoch 353, loss 34.75621032714844\n",
      "epoch 354, loss 37.79497146606445\n",
      "epoch 355, loss 42.033424377441406\n",
      "epoch 356, loss 38.663414001464844\n",
      "epoch 357, loss 39.525970458984375\n",
      "epoch 358, loss 40.51791000366211\n",
      "epoch 359, loss 34.24211120605469\n",
      "epoch 360, loss 33.80918884277344\n",
      "epoch 361, loss 30.0783634185791\n",
      "epoch 362, loss 44.972721099853516\n",
      "epoch 363, loss 35.26884460449219\n",
      "epoch 364, loss 30.010181427001953\n",
      "epoch 365, loss 40.20888137817383\n",
      "epoch 366, loss 40.91373062133789\n",
      "epoch 367, loss 34.08704376220703\n",
      "epoch 368, loss 37.17946243286133\n",
      "epoch 369, loss 39.08131790161133\n",
      "epoch 370, loss 34.67753601074219\n",
      "epoch 371, loss 36.46424865722656\n",
      "epoch 372, loss 35.52052688598633\n",
      "epoch 373, loss 31.60750389099121\n",
      "epoch 374, loss 34.83957290649414\n",
      "epoch 375, loss 28.900291442871094\n",
      "epoch 376, loss 40.57616424560547\n",
      "epoch 377, loss 39.164424896240234\n",
      "epoch 378, loss 34.22840118408203\n",
      "epoch 379, loss 36.27180099487305\n",
      "epoch 380, loss 38.432315826416016\n",
      "epoch 381, loss 33.027732849121094\n",
      "epoch 382, loss 36.122798919677734\n",
      "epoch 383, loss 32.524105072021484\n",
      "epoch 384, loss 35.14373779296875\n",
      "epoch 385, loss 39.83657455444336\n",
      "epoch 386, loss 33.99592208862305\n",
      "epoch 387, loss 32.419349670410156\n",
      "epoch 388, loss 31.713111877441406\n",
      "epoch 389, loss 40.81425476074219\n",
      "epoch 390, loss 50.75645446777344\n",
      "epoch 391, loss 30.339588165283203\n",
      "epoch 392, loss 43.71063232421875\n",
      "epoch 393, loss 25.93108367919922\n",
      "epoch 394, loss 25.39885711669922\n",
      "epoch 395, loss 34.286617279052734\n",
      "epoch 396, loss 34.893310546875\n",
      "epoch 397, loss 38.17050552368164\n",
      "epoch 398, loss 29.174781799316406\n",
      "epoch 399, loss 26.802743911743164\n",
      "epoch 400, loss 34.129539489746094\n",
      "epoch 401, loss 35.67675018310547\n",
      "epoch 402, loss 40.97292709350586\n",
      "epoch 403, loss 39.896583557128906\n",
      "epoch 404, loss 28.34719467163086\n",
      "epoch 405, loss 35.955772399902344\n",
      "epoch 406, loss 27.77625846862793\n",
      "epoch 407, loss 35.9625358581543\n",
      "epoch 408, loss 37.66268539428711\n",
      "epoch 409, loss 37.807064056396484\n",
      "epoch 410, loss 33.78314208984375\n",
      "epoch 411, loss 32.67013931274414\n",
      "epoch 412, loss 27.238187789916992\n",
      "epoch 413, loss 43.45223617553711\n",
      "epoch 414, loss 37.62240219116211\n",
      "epoch 415, loss 33.691925048828125\n",
      "epoch 416, loss 26.326093673706055\n",
      "epoch 417, loss 32.446807861328125\n",
      "epoch 418, loss 32.33977508544922\n",
      "epoch 419, loss 29.05799674987793\n",
      "epoch 420, loss 36.78568649291992\n",
      "epoch 421, loss 31.081628799438477\n",
      "epoch 422, loss 37.062744140625\n",
      "epoch 423, loss 35.157554626464844\n",
      "epoch 424, loss 34.59683609008789\n",
      "epoch 425, loss 38.01681137084961\n",
      "epoch 426, loss 25.479990005493164\n",
      "epoch 427, loss 33.55347442626953\n",
      "epoch 428, loss 48.03230667114258\n",
      "epoch 429, loss 33.291748046875\n",
      "epoch 430, loss 29.965635299682617\n",
      "epoch 431, loss 31.640581130981445\n",
      "epoch 432, loss 30.913063049316406\n",
      "epoch 433, loss 32.24776840209961\n",
      "epoch 434, loss 35.1864013671875\n",
      "epoch 435, loss 39.72975540161133\n",
      "epoch 436, loss 33.18667984008789\n",
      "epoch 437, loss 31.74452781677246\n",
      "epoch 438, loss 36.91850662231445\n",
      "epoch 439, loss 28.821849822998047\n",
      "epoch 440, loss 35.93317794799805\n",
      "epoch 441, loss 31.09494972229004\n",
      "epoch 442, loss 41.044742584228516\n",
      "epoch 443, loss 38.274261474609375\n",
      "epoch 444, loss 28.105499267578125\n",
      "epoch 445, loss 27.177410125732422\n",
      "epoch 446, loss 31.912382125854492\n",
      "epoch 447, loss 36.167579650878906\n",
      "epoch 448, loss 32.21025085449219\n",
      "epoch 449, loss 33.485145568847656\n",
      "epoch 450, loss 36.591182708740234\n",
      "epoch 451, loss 30.393993377685547\n",
      "epoch 452, loss 31.83613395690918\n",
      "epoch 453, loss 34.4627571105957\n",
      "epoch 454, loss 33.40277099609375\n",
      "epoch 455, loss 32.998268127441406\n",
      "epoch 456, loss 33.22983932495117\n",
      "epoch 457, loss 42.53842544555664\n",
      "epoch 458, loss 40.31999969482422\n",
      "epoch 459, loss 37.50083541870117\n",
      "epoch 460, loss 29.601749420166016\n",
      "epoch 461, loss 39.051151275634766\n",
      "epoch 462, loss 38.31074142456055\n",
      "epoch 463, loss 42.420379638671875\n",
      "epoch 464, loss 40.748409271240234\n",
      "epoch 465, loss 31.192811965942383\n",
      "epoch 466, loss 37.221717834472656\n",
      "epoch 467, loss 34.81740951538086\n",
      "epoch 468, loss 40.645267486572266\n",
      "epoch 469, loss 31.227384567260742\n",
      "epoch 470, loss 36.937686920166016\n",
      "epoch 471, loss 31.091693878173828\n",
      "epoch 472, loss 41.384681701660156\n",
      "epoch 473, loss 38.27007293701172\n",
      "epoch 474, loss 35.37343215942383\n",
      "epoch 475, loss 39.20734405517578\n",
      "epoch 476, loss 37.35610580444336\n",
      "epoch 477, loss 35.019012451171875\n",
      "epoch 478, loss 40.435874938964844\n",
      "epoch 479, loss 25.42721939086914\n",
      "epoch 480, loss 40.201393127441406\n",
      "epoch 481, loss 37.83287048339844\n",
      "epoch 482, loss 39.1313591003418\n",
      "epoch 483, loss 37.475364685058594\n",
      "epoch 484, loss 36.722206115722656\n",
      "epoch 485, loss 38.738616943359375\n",
      "epoch 486, loss 32.94710159301758\n",
      "epoch 487, loss 33.83684158325195\n",
      "epoch 488, loss 36.5017204284668\n",
      "epoch 489, loss 32.06364822387695\n",
      "epoch 490, loss 39.319427490234375\n",
      "epoch 491, loss 34.49320602416992\n",
      "epoch 492, loss 45.65089797973633\n",
      "epoch 493, loss 29.910999298095703\n",
      "epoch 494, loss 32.196685791015625\n",
      "epoch 495, loss 27.867088317871094\n",
      "epoch 496, loss 38.300201416015625\n",
      "epoch 497, loss 31.290096282958984\n",
      "epoch 498, loss 33.887786865234375\n",
      "epoch 499, loss 42.877288818359375\n",
      "epoch 500, loss 42.76396560668945\n",
      "epoch 501, loss 40.14259338378906\n",
      "epoch 502, loss 32.995338439941406\n",
      "epoch 503, loss 42.5135383605957\n",
      "epoch 504, loss 41.18927001953125\n",
      "epoch 505, loss 31.63242530822754\n",
      "epoch 506, loss 38.63288497924805\n",
      "epoch 507, loss 27.940839767456055\n",
      "epoch 508, loss 33.511226654052734\n",
      "epoch 509, loss 32.698692321777344\n",
      "epoch 510, loss 33.26716613769531\n",
      "epoch 511, loss 37.16040802001953\n",
      "epoch 512, loss 35.20132064819336\n",
      "epoch 513, loss 40.343467712402344\n",
      "epoch 514, loss 33.54106521606445\n",
      "epoch 515, loss 40.55332946777344\n",
      "epoch 516, loss 44.497989654541016\n",
      "epoch 517, loss 28.065969467163086\n",
      "epoch 518, loss 30.09896469116211\n",
      "epoch 519, loss 39.470550537109375\n",
      "epoch 520, loss 37.2725944519043\n",
      "epoch 521, loss 34.62263488769531\n",
      "epoch 522, loss 38.8272590637207\n",
      "epoch 523, loss 35.80254364013672\n",
      "epoch 524, loss 40.47452163696289\n",
      "epoch 525, loss 34.7481575012207\n",
      "epoch 526, loss 30.074743270874023\n",
      "epoch 527, loss 29.3671817779541\n",
      "epoch 528, loss 35.48059844970703\n",
      "epoch 529, loss 39.97306442260742\n",
      "epoch 530, loss 32.42787170410156\n",
      "epoch 531, loss 36.015132904052734\n",
      "epoch 532, loss 30.484468460083008\n",
      "epoch 533, loss 35.17628479003906\n",
      "epoch 534, loss 38.199058532714844\n",
      "epoch 535, loss 29.393381118774414\n",
      "epoch 536, loss 34.93537521362305\n",
      "epoch 537, loss 32.3232307434082\n",
      "epoch 538, loss 35.672462463378906\n",
      "epoch 539, loss 29.33817481994629\n",
      "epoch 540, loss 33.0769157409668\n",
      "epoch 541, loss 29.81365966796875\n",
      "epoch 542, loss 35.10194396972656\n",
      "epoch 543, loss 31.646215438842773\n",
      "epoch 544, loss 33.54139709472656\n",
      "epoch 545, loss 42.461727142333984\n",
      "epoch 546, loss 39.3814811706543\n",
      "epoch 547, loss 34.65232849121094\n",
      "epoch 548, loss 44.453590393066406\n",
      "epoch 549, loss 36.273658752441406\n",
      "epoch 550, loss 36.97847366333008\n",
      "epoch 551, loss 39.2202262878418\n",
      "epoch 552, loss 40.885066986083984\n",
      "epoch 553, loss 36.60713577270508\n",
      "epoch 554, loss 40.644344329833984\n",
      "epoch 555, loss 37.391841888427734\n",
      "epoch 556, loss 29.8928279876709\n",
      "epoch 557, loss 33.03893280029297\n",
      "epoch 558, loss 39.32691955566406\n",
      "epoch 559, loss 33.90231704711914\n",
      "epoch 560, loss 35.86809539794922\n",
      "epoch 561, loss 38.12291717529297\n",
      "epoch 562, loss 43.4390869140625\n",
      "epoch 563, loss 46.7469596862793\n",
      "epoch 564, loss 29.11173439025879\n",
      "epoch 565, loss 33.03483200073242\n",
      "epoch 566, loss 35.44762420654297\n",
      "epoch 567, loss 37.598934173583984\n",
      "epoch 568, loss 28.61488151550293\n",
      "epoch 569, loss 41.69956588745117\n",
      "epoch 570, loss 34.45511245727539\n",
      "epoch 571, loss 35.616790771484375\n",
      "epoch 572, loss 31.105350494384766\n",
      "epoch 573, loss 38.07946014404297\n",
      "epoch 574, loss 33.941871643066406\n",
      "epoch 575, loss 38.41279602050781\n",
      "epoch 576, loss 32.30819320678711\n",
      "epoch 577, loss 28.80607795715332\n",
      "epoch 578, loss 36.82341766357422\n",
      "epoch 579, loss 37.63285827636719\n",
      "epoch 580, loss 33.71615982055664\n",
      "epoch 581, loss 34.426021575927734\n",
      "epoch 582, loss 38.46796417236328\n",
      "epoch 583, loss 34.43471145629883\n",
      "epoch 584, loss 37.75053024291992\n",
      "epoch 585, loss 36.98720932006836\n",
      "epoch 586, loss 39.61128234863281\n",
      "epoch 587, loss 32.23706817626953\n",
      "epoch 588, loss 29.7227783203125\n",
      "epoch 589, loss 30.609500885009766\n",
      "epoch 590, loss 34.96571731567383\n",
      "epoch 591, loss 35.602073669433594\n",
      "epoch 592, loss 37.17501449584961\n",
      "epoch 593, loss 37.69229507446289\n",
      "epoch 594, loss 36.888580322265625\n",
      "epoch 595, loss 35.24066925048828\n",
      "epoch 596, loss 38.06342315673828\n",
      "epoch 597, loss 35.80299758911133\n",
      "epoch 598, loss 40.825016021728516\n",
      "epoch 599, loss 35.52228927612305\n",
      "epoch 600, loss 38.335994720458984\n",
      "epoch 601, loss 33.56038284301758\n",
      "epoch 602, loss 32.83938980102539\n",
      "epoch 603, loss 34.96767044067383\n",
      "epoch 604, loss 34.784427642822266\n",
      "epoch 605, loss 36.378292083740234\n",
      "epoch 606, loss 43.27107620239258\n",
      "epoch 607, loss 37.35720443725586\n",
      "epoch 608, loss 38.752586364746094\n",
      "epoch 609, loss 36.47042465209961\n",
      "epoch 610, loss 34.51993942260742\n",
      "epoch 611, loss 37.186946868896484\n",
      "epoch 612, loss 40.4171028137207\n",
      "epoch 613, loss 32.57362747192383\n",
      "epoch 614, loss 36.158573150634766\n",
      "epoch 615, loss 39.66445541381836\n",
      "epoch 616, loss 26.13170051574707\n",
      "epoch 617, loss 41.41777038574219\n",
      "epoch 618, loss 32.050785064697266\n",
      "epoch 619, loss 34.08698272705078\n",
      "epoch 620, loss 30.30922508239746\n",
      "epoch 621, loss 31.7851505279541\n",
      "epoch 622, loss 42.97760772705078\n",
      "epoch 623, loss 34.298362731933594\n",
      "epoch 624, loss 34.33839797973633\n",
      "epoch 625, loss 32.87710952758789\n",
      "epoch 626, loss 30.644163131713867\n",
      "epoch 627, loss 43.05305480957031\n",
      "epoch 628, loss 34.36209487915039\n",
      "epoch 629, loss 35.48854446411133\n",
      "epoch 630, loss 36.39821243286133\n",
      "epoch 631, loss 30.82082176208496\n",
      "epoch 632, loss 34.943321228027344\n",
      "epoch 633, loss 30.040159225463867\n",
      "epoch 634, loss 31.474491119384766\n",
      "epoch 635, loss 32.67774200439453\n",
      "epoch 636, loss 35.295413970947266\n",
      "epoch 637, loss 32.8897705078125\n",
      "epoch 638, loss 40.30537033081055\n",
      "epoch 639, loss 35.904510498046875\n",
      "epoch 640, loss 34.94573974609375\n",
      "epoch 641, loss 31.13313102722168\n",
      "epoch 642, loss 36.759788513183594\n",
      "epoch 643, loss 28.678508758544922\n",
      "epoch 644, loss 37.04252624511719\n",
      "epoch 645, loss 36.778507232666016\n",
      "epoch 646, loss 44.03004455566406\n",
      "epoch 647, loss 30.517749786376953\n",
      "epoch 648, loss 31.044095993041992\n",
      "epoch 649, loss 42.676761627197266\n",
      "epoch 650, loss 28.63847541809082\n",
      "epoch 651, loss 30.758012771606445\n",
      "epoch 652, loss 35.4398078918457\n",
      "epoch 653, loss 36.76165771484375\n",
      "epoch 654, loss 36.475101470947266\n",
      "epoch 655, loss 39.799537658691406\n",
      "epoch 656, loss 34.26792907714844\n",
      "epoch 657, loss 36.33006286621094\n",
      "epoch 658, loss 37.52650833129883\n",
      "epoch 659, loss 35.0419921875\n",
      "epoch 660, loss 33.62218475341797\n",
      "epoch 661, loss 29.518218994140625\n",
      "epoch 662, loss 33.496158599853516\n",
      "epoch 663, loss 46.059268951416016\n",
      "epoch 664, loss 36.77497482299805\n",
      "epoch 665, loss 37.69110107421875\n",
      "epoch 666, loss 32.94914627075195\n",
      "epoch 667, loss 36.35404586791992\n",
      "epoch 668, loss 34.59096145629883\n",
      "epoch 669, loss 33.385955810546875\n",
      "epoch 670, loss 30.503633499145508\n",
      "epoch 671, loss 40.03521728515625\n",
      "epoch 672, loss 34.26838302612305\n",
      "epoch 673, loss 40.675392150878906\n",
      "epoch 674, loss 39.16147232055664\n",
      "epoch 675, loss 32.15016555786133\n",
      "epoch 676, loss 36.95439529418945\n",
      "epoch 677, loss 37.80701446533203\n",
      "epoch 678, loss 33.52136993408203\n",
      "epoch 679, loss 33.56126403808594\n",
      "epoch 680, loss 37.68997573852539\n",
      "epoch 681, loss 37.19516372680664\n",
      "epoch 682, loss 33.8414192199707\n",
      "epoch 683, loss 33.554176330566406\n",
      "epoch 684, loss 25.91672134399414\n",
      "epoch 685, loss 24.145719528198242\n",
      "epoch 686, loss 32.45269012451172\n",
      "epoch 687, loss 33.56542205810547\n",
      "epoch 688, loss 31.985755920410156\n",
      "epoch 689, loss 40.46969223022461\n",
      "epoch 690, loss 30.51957130432129\n",
      "epoch 691, loss 32.482120513916016\n",
      "epoch 692, loss 36.32106399536133\n",
      "epoch 693, loss 36.49791717529297\n",
      "epoch 694, loss 37.548526763916016\n",
      "epoch 695, loss 33.43511199951172\n",
      "epoch 696, loss 32.71986389160156\n",
      "epoch 697, loss 34.06566619873047\n",
      "epoch 698, loss 30.566064834594727\n",
      "epoch 699, loss 36.24289321899414\n",
      "epoch 700, loss 28.97115707397461\n",
      "epoch 701, loss 38.11335754394531\n",
      "epoch 702, loss 29.42120933532715\n",
      "epoch 703, loss 33.326908111572266\n",
      "epoch 704, loss 37.37917709350586\n",
      "epoch 705, loss 30.938884735107422\n",
      "epoch 706, loss 38.57764434814453\n",
      "epoch 707, loss 35.616695404052734\n",
      "epoch 708, loss 30.135684967041016\n",
      "epoch 709, loss 29.940828323364258\n",
      "epoch 710, loss 37.73365020751953\n",
      "epoch 711, loss 45.78374481201172\n",
      "epoch 712, loss 31.546703338623047\n",
      "epoch 713, loss 41.115230560302734\n",
      "epoch 714, loss 31.56586265563965\n",
      "epoch 715, loss 35.59609603881836\n",
      "epoch 716, loss 35.38861083984375\n",
      "epoch 717, loss 33.644222259521484\n",
      "epoch 718, loss 32.86904525756836\n",
      "epoch 719, loss 36.681156158447266\n",
      "epoch 720, loss 34.4410285949707\n",
      "epoch 721, loss 30.263710021972656\n",
      "epoch 722, loss 22.07890510559082\n",
      "epoch 723, loss 44.98301696777344\n",
      "epoch 724, loss 34.18889236450195\n",
      "epoch 725, loss 31.27491569519043\n",
      "epoch 726, loss 26.908105850219727\n",
      "epoch 727, loss 28.169687271118164\n",
      "epoch 728, loss 29.040624618530273\n",
      "epoch 729, loss 45.97672653198242\n",
      "epoch 730, loss 33.99896240234375\n",
      "epoch 731, loss 37.93241500854492\n",
      "epoch 732, loss 37.758724212646484\n",
      "epoch 733, loss 35.328311920166016\n",
      "epoch 734, loss 39.378501892089844\n",
      "epoch 735, loss 30.29731559753418\n",
      "epoch 736, loss 30.249441146850586\n",
      "epoch 737, loss 34.32217788696289\n",
      "epoch 738, loss 34.49150848388672\n",
      "epoch 739, loss 36.8820686340332\n",
      "epoch 740, loss 31.15198516845703\n",
      "epoch 741, loss 38.32760238647461\n",
      "epoch 742, loss 40.91904067993164\n",
      "epoch 743, loss 37.202545166015625\n",
      "epoch 744, loss 36.34794235229492\n",
      "epoch 745, loss 37.183292388916016\n",
      "epoch 746, loss 30.858793258666992\n",
      "epoch 747, loss 35.10508346557617\n",
      "epoch 748, loss 31.944068908691406\n",
      "epoch 749, loss 37.606807708740234\n",
      "epoch 750, loss 30.442106246948242\n",
      "epoch 751, loss 32.98768615722656\n",
      "epoch 752, loss 26.135522842407227\n",
      "epoch 753, loss 36.3385009765625\n",
      "epoch 754, loss 43.70134735107422\n",
      "epoch 755, loss 38.9638786315918\n",
      "epoch 756, loss 39.632286071777344\n",
      "epoch 757, loss 33.88492965698242\n",
      "epoch 758, loss 38.081966400146484\n",
      "epoch 759, loss 30.735183715820312\n",
      "epoch 760, loss 33.16946792602539\n",
      "epoch 761, loss 31.419677734375\n",
      "epoch 762, loss 38.10331726074219\n",
      "epoch 763, loss 32.4608268737793\n",
      "epoch 764, loss 39.81473159790039\n",
      "epoch 765, loss 44.24666213989258\n",
      "epoch 766, loss 38.82289505004883\n",
      "epoch 767, loss 33.704742431640625\n",
      "epoch 768, loss 41.449798583984375\n",
      "epoch 769, loss 40.36822509765625\n",
      "epoch 770, loss 33.907432556152344\n",
      "epoch 771, loss 29.916696548461914\n",
      "epoch 772, loss 28.491437911987305\n",
      "epoch 773, loss 34.4920768737793\n",
      "epoch 774, loss 39.87367248535156\n",
      "epoch 775, loss 28.271488189697266\n",
      "epoch 776, loss 42.18930435180664\n",
      "epoch 777, loss 42.21989440917969\n",
      "epoch 778, loss 38.01838302612305\n",
      "epoch 779, loss 24.991802215576172\n",
      "epoch 780, loss 28.274490356445312\n",
      "epoch 781, loss 31.01088523864746\n",
      "epoch 782, loss 34.21636962890625\n",
      "epoch 783, loss 24.81195068359375\n",
      "epoch 784, loss 38.809715270996094\n",
      "epoch 785, loss 38.662044525146484\n",
      "epoch 786, loss 42.668460845947266\n",
      "epoch 787, loss 41.2051887512207\n",
      "epoch 788, loss 34.75129699707031\n",
      "epoch 789, loss 25.507211685180664\n",
      "epoch 790, loss 41.843353271484375\n",
      "epoch 791, loss 35.412864685058594\n",
      "epoch 792, loss 29.718441009521484\n",
      "epoch 793, loss 36.95855712890625\n",
      "epoch 794, loss 33.20881652832031\n",
      "epoch 795, loss 33.780426025390625\n",
      "epoch 796, loss 26.857324600219727\n",
      "epoch 797, loss 38.19969177246094\n",
      "epoch 798, loss 34.60580062866211\n",
      "epoch 799, loss 37.71150207519531\n",
      "epoch 800, loss 29.987092971801758\n",
      "epoch 801, loss 24.71525001525879\n",
      "epoch 802, loss 40.13393783569336\n",
      "epoch 803, loss 36.71974182128906\n",
      "epoch 804, loss 32.987911224365234\n",
      "epoch 805, loss 37.52177047729492\n",
      "epoch 806, loss 25.401371002197266\n",
      "epoch 807, loss 35.02132034301758\n",
      "epoch 808, loss 38.39754867553711\n",
      "epoch 809, loss 30.810611724853516\n",
      "epoch 810, loss 40.750492095947266\n",
      "epoch 811, loss 40.54252243041992\n",
      "epoch 812, loss 35.34665298461914\n",
      "epoch 813, loss 33.651573181152344\n",
      "epoch 814, loss 37.449100494384766\n",
      "epoch 815, loss 37.28343200683594\n",
      "epoch 816, loss 43.76273727416992\n",
      "epoch 817, loss 38.76199722290039\n",
      "epoch 818, loss 32.51680374145508\n",
      "epoch 819, loss 39.12103271484375\n",
      "epoch 820, loss 40.32106018066406\n",
      "epoch 821, loss 28.943986892700195\n",
      "epoch 822, loss 37.7564811706543\n",
      "epoch 823, loss 36.944339752197266\n",
      "epoch 824, loss 37.23988723754883\n",
      "epoch 825, loss 26.426050186157227\n",
      "epoch 826, loss 34.867801666259766\n",
      "epoch 827, loss 40.66571807861328\n",
      "epoch 828, loss 38.205387115478516\n",
      "epoch 829, loss 31.513755798339844\n",
      "epoch 830, loss 34.10599899291992\n",
      "epoch 831, loss 38.562931060791016\n",
      "epoch 832, loss 34.76573181152344\n",
      "epoch 833, loss 39.60865020751953\n",
      "epoch 834, loss 32.667972564697266\n",
      "epoch 835, loss 35.54994201660156\n",
      "epoch 836, loss 44.857479095458984\n",
      "epoch 837, loss 34.43760681152344\n",
      "epoch 838, loss 41.2677001953125\n",
      "epoch 839, loss 41.829002380371094\n",
      "epoch 840, loss 34.43968963623047\n",
      "epoch 841, loss 27.889694213867188\n",
      "epoch 842, loss 35.66781997680664\n",
      "epoch 843, loss 38.486698150634766\n",
      "epoch 844, loss 29.696971893310547\n",
      "epoch 845, loss 35.99031066894531\n",
      "epoch 846, loss 37.3030891418457\n",
      "epoch 847, loss 40.089359283447266\n",
      "epoch 848, loss 37.638248443603516\n",
      "epoch 849, loss 34.236385345458984\n",
      "epoch 850, loss 32.64247512817383\n",
      "epoch 851, loss 34.87977981567383\n",
      "epoch 852, loss 36.96076965332031\n",
      "epoch 853, loss 43.24818420410156\n",
      "epoch 854, loss 40.92594909667969\n",
      "epoch 855, loss 34.590763092041016\n",
      "epoch 856, loss 30.768390655517578\n",
      "epoch 857, loss 40.81761932373047\n",
      "epoch 858, loss 43.72239303588867\n",
      "epoch 859, loss 35.59067153930664\n",
      "epoch 860, loss 35.781864166259766\n",
      "epoch 861, loss 31.312480926513672\n",
      "epoch 862, loss 35.25693893432617\n",
      "epoch 863, loss 38.438751220703125\n",
      "epoch 864, loss 36.914852142333984\n",
      "epoch 865, loss 43.66743087768555\n",
      "epoch 866, loss 37.660430908203125\n",
      "epoch 867, loss 35.19651412963867\n",
      "epoch 868, loss 31.904508590698242\n",
      "epoch 869, loss 34.28105545043945\n",
      "epoch 870, loss 35.31386947631836\n",
      "epoch 871, loss 34.92912673950195\n",
      "epoch 872, loss 36.79655838012695\n",
      "epoch 873, loss 40.147926330566406\n",
      "epoch 874, loss 38.37835693359375\n",
      "epoch 875, loss 29.821619033813477\n",
      "epoch 876, loss 29.072765350341797\n",
      "epoch 877, loss 36.96039962768555\n",
      "epoch 878, loss 33.29802322387695\n",
      "epoch 879, loss 32.9181022644043\n",
      "epoch 880, loss 33.9923095703125\n",
      "epoch 881, loss 35.93705749511719\n",
      "epoch 882, loss 39.037994384765625\n",
      "epoch 883, loss 36.62160873413086\n",
      "epoch 884, loss 39.59935760498047\n",
      "epoch 885, loss 38.89781951904297\n",
      "epoch 886, loss 43.212406158447266\n",
      "epoch 887, loss 37.54637908935547\n",
      "epoch 888, loss 34.922000885009766\n",
      "epoch 889, loss 42.8401985168457\n",
      "epoch 890, loss 36.7161865234375\n",
      "epoch 891, loss 28.94365692138672\n",
      "epoch 892, loss 35.169769287109375\n",
      "epoch 893, loss 36.83345031738281\n",
      "epoch 894, loss 31.828845977783203\n",
      "epoch 895, loss 28.70421600341797\n",
      "epoch 896, loss 38.2559928894043\n",
      "epoch 897, loss 26.801334381103516\n",
      "epoch 898, loss 43.540016174316406\n",
      "epoch 899, loss 43.43547821044922\n",
      "epoch 900, loss 35.2391242980957\n",
      "epoch 901, loss 35.28824234008789\n",
      "epoch 902, loss 36.403160095214844\n",
      "epoch 903, loss 33.492130279541016\n",
      "epoch 904, loss 29.58736801147461\n",
      "epoch 905, loss 45.63831329345703\n",
      "epoch 906, loss 34.10295104980469\n",
      "epoch 907, loss 36.36940383911133\n",
      "epoch 908, loss 36.996456146240234\n",
      "epoch 909, loss 41.18846130371094\n",
      "epoch 910, loss 34.754093170166016\n",
      "epoch 911, loss 33.63637924194336\n",
      "epoch 912, loss 34.122718811035156\n",
      "epoch 913, loss 32.8465576171875\n",
      "epoch 914, loss 32.30186080932617\n",
      "epoch 915, loss 32.679420471191406\n",
      "epoch 916, loss 40.3958740234375\n",
      "epoch 917, loss 33.652870178222656\n",
      "epoch 918, loss 32.853206634521484\n",
      "epoch 919, loss 38.93016052246094\n",
      "epoch 920, loss 35.21262741088867\n",
      "epoch 921, loss 35.18046569824219\n",
      "epoch 922, loss 40.69648742675781\n",
      "epoch 923, loss 38.94879150390625\n",
      "epoch 924, loss 29.612625122070312\n",
      "epoch 925, loss 29.7268009185791\n",
      "epoch 926, loss 37.55047607421875\n",
      "epoch 927, loss 38.333717346191406\n",
      "epoch 928, loss 37.62385177612305\n",
      "epoch 929, loss 33.0120735168457\n",
      "epoch 930, loss 35.66219711303711\n",
      "epoch 931, loss 37.93488311767578\n",
      "epoch 932, loss 29.6899471282959\n",
      "epoch 933, loss 41.415306091308594\n",
      "epoch 934, loss 33.82009506225586\n",
      "epoch 935, loss 37.391841888427734\n",
      "epoch 936, loss 35.64737319946289\n",
      "epoch 937, loss 34.34152603149414\n",
      "epoch 938, loss 44.60502624511719\n",
      "epoch 939, loss 35.43159484863281\n",
      "epoch 940, loss 36.12531280517578\n",
      "epoch 941, loss 32.2020263671875\n",
      "epoch 942, loss 31.829416275024414\n",
      "epoch 943, loss 38.56818389892578\n",
      "epoch 944, loss 34.87590026855469\n",
      "epoch 945, loss 38.7853889465332\n",
      "epoch 946, loss 33.9604606628418\n",
      "epoch 947, loss 35.58938217163086\n",
      "epoch 948, loss 36.95423889160156\n",
      "epoch 949, loss 28.489171981811523\n",
      "epoch 950, loss 42.704750061035156\n",
      "epoch 951, loss 40.68192672729492\n",
      "epoch 952, loss 33.586360931396484\n",
      "epoch 953, loss 39.610774993896484\n",
      "epoch 954, loss 35.963539123535156\n",
      "epoch 955, loss 32.87632751464844\n",
      "epoch 956, loss 29.670984268188477\n",
      "epoch 957, loss 38.5837516784668\n",
      "epoch 958, loss 28.70511817932129\n",
      "epoch 959, loss 36.718528747558594\n",
      "epoch 960, loss 31.14310646057129\n",
      "epoch 961, loss 36.324317932128906\n",
      "epoch 962, loss 35.342960357666016\n",
      "epoch 963, loss 33.99310302734375\n",
      "epoch 964, loss 35.50477981567383\n",
      "epoch 965, loss 39.223262786865234\n",
      "epoch 966, loss 28.379772186279297\n",
      "epoch 967, loss 33.741573333740234\n",
      "epoch 968, loss 39.54804229736328\n",
      "epoch 969, loss 36.50065612792969\n",
      "epoch 970, loss 36.979732513427734\n",
      "epoch 971, loss 37.4460334777832\n",
      "epoch 972, loss 41.121517181396484\n",
      "epoch 973, loss 36.94685745239258\n",
      "epoch 974, loss 42.70856475830078\n",
      "epoch 975, loss 41.13801574707031\n",
      "epoch 976, loss 41.56125259399414\n",
      "epoch 977, loss 46.419097900390625\n",
      "epoch 978, loss 35.16782760620117\n",
      "epoch 979, loss 39.18985366821289\n",
      "epoch 980, loss 32.328582763671875\n",
      "epoch 981, loss 41.28291320800781\n",
      "epoch 982, loss 34.21894073486328\n",
      "epoch 983, loss 30.914081573486328\n",
      "epoch 984, loss 31.678335189819336\n",
      "epoch 985, loss 36.43510055541992\n",
      "epoch 986, loss 53.08833694458008\n",
      "epoch 987, loss 27.486997604370117\n",
      "epoch 988, loss 34.02923583984375\n",
      "epoch 989, loss 32.49611282348633\n",
      "epoch 990, loss 27.037044525146484\n",
      "epoch 991, loss 31.917831420898438\n",
      "epoch 992, loss 33.35333251953125\n",
      "epoch 993, loss 34.83778762817383\n",
      "epoch 994, loss 33.11488342285156\n",
      "epoch 995, loss 35.45747375488281\n",
      "epoch 996, loss 39.982147216796875\n",
      "epoch 997, loss 41.98576736450195\n",
      "epoch 998, loss 45.97319793701172\n",
      "epoch 999, loss 39.62946701049805\n"
     ]
    }
   ],
   "execution_count": 11
  }
 ],
 "metadata": {
  "language_info": {
   "name": "python"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 5
}
